﻿var xpath = "http://" +location.host+ "/SSTA/common/agent/";


function getProvince_o() {
	var url = xpath + "getprovince.jsp";
    XmlHttpPool.GetRemoteData(url, showProvinceList);
      
}

function showProvinceList(data) {
    //var xml = new ActiveXObject("Microsoft.XMLDOM");
	//xml.loadXML(data);
	//alert(data);
	
	//alert(data);
	var data = eval("("+data+")");
	 
	//var tempobj = xml.documentElement;
	if(data!=null) {
	    var option = null;	    
	    //var nodeid = tempobj.selectNodes("//id");
	    //var nodename = tempobj.selectNodes("//name");
	    
	    //var len = nodeid.length;
	    var i = 0;
        var str = "";
	    for(i = 0; i < data.length; i++) {
	        option = document.createElement("OPTION");
            option.text = data[i]['name'];
            option.value = data[i]['id'];
            document.getElementById("province").options.add(option);
	    } 
	}
}

function getProvince() {	
	 url = xpath + "getprovince.jsp";	
     LoadXml();
	
	 var option = null;
	 var nodeid ;
	 var nodename;
	 var len;
	 var i=0;
	 if (browse=="ie"){
	 	
             nodeid = xml.selectNodes("//id");                    		
             nodename = xml.selectNodes("//name");
	     len = nodeid.length;
	       
	     for(i = 0; i < len; i++) {

	        option = document.createElement("OPTION");
                option.text = nodename.item(i).text;
                option.value = nodeid.item(i).text;
                document.getElementById("province").options.add(option);               
	     }                  	                	
          }
                
          if (browse=="ff") {
              if(xml.getElementsByTagName("id") != null)
                	nodeid =xml.getElementsByTagName("id");               		
              nodename = xml.getElementsByTagName("name");
	      len = nodeid.length;
	    
	      for(i = 0; i < len; i++) {

	        option = document.createElement("OPTION");
                option.text = xml.getElementsByTagName("name")[i].childNodes[0].nodeValue;
                option.value = xml.getElementsByTagName("id")[i].childNodes[0].nodeValue;
                document.getElementById("province").appendChild(option);
               
	      }    
           }	    
	   	
}

function getZdxxByZddmXxdm(zddm,xxdm) {
        
	var url = xpath + "getzdxx.jsp?zddm="+zddm+"&xxdm="+xxdm+"&nocache="+new Date().getTime();
	XmlHttpPool.GetRemoteData(url, showXxdmList);	
}


function showXxdmList(data) {
    //var xml = new ActiveXObject("Microsoft.XMLDOM");
   // xml.async="false" ;
	//xml.loadXML(data);
	//var tempobj = xml.documentElement;
	
	var data = eval("("+data+")");
	
	if(data!=null) {
               //var zddm = xml.documentElement.selectSingleNode("//zddm").text
               //var xxdm = xml.documentElement.selectSingleNode("//xxdm").text
        	   
        	   zddm = data[0]['zddm'];
        	   xxdm = data[0]['xxdm'];
        	   
               var option = null;
               option = document.createElement("OPTION");
               option.text = '请选择';
               option.value = '';
               
               if (xxdm == "") {
                     option.selected = true;
               }
               
               document.getElementById(zddm).options.add(option);
               
               var nodelist = tempobj.selectNodes("//id");
               for(j = 0; j < data.length; j++) {
	            	option = document.createElement("OPTION");
                    option.text = data[j]['name'];
                    option.value = data[j]['id'];
                    
                    if (xxdm!=null && xxdm!="") {
                       if (trim(xxdm4) == trim(option.value)){
                             option.selected = true;
                       }
                    }
               	    document.getElementById(zddm).options.add(option);
	        }
	       
	}
}

function getOption(tablename,optionname,optionval) {
       
	 url = xpath + "getoption.jsp?tablename="+tablename+"&optionname="+optionname+"&optionval="+optionval+"&nocache="+new Date().getTime();
	 LoadXml();
	 var option = null;
	 var nodeid ;
	 var nodename;
	 var len;
	 var i=0;
	 var optionname="";
	 var optionval="";
	 if (browse=="ie"){
	  	optionname = xml.documentElement.selectSingleNode("//optionname").text;
                optionval = xml.documentElement.selectSingleNode("//optionval").text;
                 
		nodeid = xml.selectNodes("//id");                    		
             	nodename = xml.selectNodes("//name");
             	option = document.createElement("OPTION");
             	option.text = '请选择';
               	option.value = '';
                if (optionval == "") {
                	option.selected = true;
                }
               	document.getElementById(optionname).options.add(option);
	     	len = nodeid.length;	     
	     	for(i = 0; i < len; i++) {
	        	option = document.createElement("OPTION");
                	option.text = nodename.item(i).text;
                	option.value = nodeid.item(i).text;
                 	if (optionval!=null && optionval!="") {
                       		if (trim(optionval) == trim(option.value)){
                             		option.selected = true;
                       		}
                    	}                   
                	document.getElementById(optionname).options.add(option);            
	     }                  	                	
          }
                
          if (browse=="ff") {          	
          	optionname = xml.getElementsByTagName("optionname")[0].childNodes[0].nodeValue;
              
              	if(xml.getElementsByTagName("id") != null)
                	nodeid =xml.getElementsByTagName("id");               		
              	nodename = xml.getElementsByTagName("name");
              	option = document.createElement("OPTION");
             	option.text = '请选择';
               	option.value = '';
                if (optionval == "") {
                     option.selected = true;
               	}
                document.getElementById(optionname).appendChild(option);
	        len = nodeid.length;
	    
	        for(i = 0; i < len; i++) {
	        	option = document.createElement("OPTION");
                	option.text = xml.getElementsByTagName("name")[i].childNodes[0].nodeValue;
                	option.value = xml.getElementsByTagName("id")[i].childNodes[0].nodeValue;
                	if (optionval!=null && optionval!="") {
                       		if (trim(optionval) == trim(option.value)){
                             		option.selected = true;
                       		}
                    	}
                	document.getElementById(optionname).appendChild(option);                   
	      	}    
           }	    	 	
}

function getOption_o(tablename,optionname,optionval) {
        
	var url = xpath + "getoption.jsp?tablename="+tablename+"&optionname="+optionname+"&optionval="+optionval+"&nocache="+new Date().getTime();
	XmlHttpPool.GetRemoteData(url,showOptionList);	
}


function showOptionList(str2) {
    
    //var str1="[ { 'optionname':'NewEnergyClass'},{ 'name':'安全标准与理论','id':'1'},{ 'name':'安全管理','id':'2'},{ 'name':'矿山安全','id':'3'},{ 'name':'——矿井大气','id':'3.1'},{ 'name':'——矿井通风','id':'3.2'},{ 'name':'——岩石沉陷及安全措施','id':'3.3'},{ 'name':'——矿山排水与堵水','id':'3.4'},{ 'name':'——矿山防火','id':'3.5'},{ 'name':'——矿山安全监测系统','id':'3.6'},{ 'name':'——矿山事故及救护','id':'3.7'},{ 'name':'——矿山卫生与劳动安全','id':'3.8'},{ 'name':'安全工程','id':'4'},{ 'name':'——石油化工安全','id':'4.1'},{ 'name':'——电气安全','id':'4.2'},{ 'name':'——建筑施工安全','id':'4.3'},{ 'name':'——航空航天安全','id':'4.4'},{ 'name':'——交通运输安全','id':'4.5'},{ 'name':'——其他','id':'4.6'},{ 'name':'劳动卫生','id':'5'}]";    
    //var str1 = data;
	var data = eval("("+str2+")");
	//alert(data);
	if(data!=null) {
        	   var optionname = data[0]['optionname'];
        	   var optionval = data[0]['optionval'];
        	   
               var option = null;
               option = document.createElement("OPTION");
               option.text = '请选择';
               option.value = '';
               if (optionval == "") {
                     option.selected = true;
               }
               
               document.getElementById(optionname).options.add(option);
               
               for(j = 1; j < data.length; j++) {
	           	    option = document.createElement("OPTION");
                    option.text = data[j]['name'];
                    option.value = data[j]['id'];
                    
                    if (optionval!=null && optionval!="") {
                       if (trim(optionval) == trim(option.value)){
                             option.selected = true;
                       }
                    }
                document.getElementById(optionname).options.add(option);
	        }
	  }
}




function getCheckOption(tablename,optionname,optionval) {
        
	var url = xpath + "getoption.jsp?type=check&tablename="+tablename+"&optionname="+optionname+"&optionval="+optionval+"&nocache="+new Date().getTime();
	XmlHttpPool.GetRemoteData(url,showCheckBoxList);	 
}


function showCheckBoxList(data){
	
	
	var data = eval("("+data+")");
	
	var str = "";
	var str1 = "";
	var str2 = "";
	var str3 = "";
	var str_begin ="";
	var str_end ="";
	var str_t ="";
	
	 var optionname = data[0]['optionname'];
	 var optionval = data[0]['optionval'];
	 
	 
	 var optionname1 = optionname+"1";
	
	// var optionval1 = optionval;
	if(data!= null) {
	    //var nodelist = xml.documentElement.selectNodes("//id");
	    //var len = nodelist.length;
	  if(data.length > 0){
		   for(var i=1;i<data.length;i++){
		        if (trim(data[i]['id'])==trim(optionval)){ 
	    			str += "<input type=\"checkbox\" name=\""+optionname+"\" value=\""+data[i]['id']+"\"  checked='true'>"+data[i]['name'];
		     	}else {
		     	  str += "<input type=\"checkbox\" name=\""+optionname+"\" value=\""+data[i]['id']+"\">"+data[i]['name'];
		     	}
		   }
	  }
	
	  if (document.getElementById("optionname1") !=null){
			document.getElementById("optionname1").innerHTML = str;
	  }
	  
	  if(document.getElementById(optionname1) !=null ){
	  	if (document.getElementById(optionname1) !=null){
			document.getElementById(optionname1).innerHTML = str;
	 	 }
	  }
	  
	}
	
}


function getZdxxByZddmXxdmCheck(zddm,xxdm) {
        
	var url = xpath + "getzdxx.jsp?zddm="+zddm+"&xxdm="+xxdm+"&nocache="+new Date().getTime();
	XmlHttpPool.GetRemoteData(url, showCheckBoxListZdxx);	
}




function showCheckBoxListZdxx(data){
	
	var str = "";
	var str1 = "";
	var str2 = "";
	var str3 = "";
	var str_begin ="";
	var str_end ="";
	var str_t ="";
	
	var data = eval("("+data+")");
	
	
	
	
	 var zddm = data[0][0];
	 var xxdm = data[0]['xxdm'];
	 
	 for (var key in data[0]) {
		//alert("key = " + key + " value = " + data[0][key]);
		zddm = key;
	 }
	 
	 
	//alert(zddm);
	 var zddm1 = zddm+"a";
	 if(data != null) {
	  if(data.length > 0) {
		    for (var i=1;i<data.length;i++){
		        if(xxdm!=null && (trim(data[i]['id']) ==trim(xxdm))){
		        	
	    			str += "<input type=\"checkbox\"    name=\""+zddm+"\" value=\""+data[i]['id']+"\" checked='true'>"+data[i]['name'];
	    		}else{
	    			
	    			str += "<input type=\"checkbox\"    name=\""+zddm+"\" value=\""+data[i]['id']+"\">"+data[i]['name'];
	    		}
		    }
	  }
	  
	  if (document.getElementById(zddm1) !=null){
			document.getElementById(zddm1).innerHTML = str;
	  }
	  
	  if(document.getElementById("item_16a") !=null){
	  		document.getElementById("item_16a").innerHTML = str;
	  }
	  
	 // alert(str);
	  
	}
	
}





